package com.xm.controller;

import com.github.pagehelper.PageInfo;
import com.xm.pojo.Psychology;
import com.xm.pojo.search.PsySearch;
import com.xm.pojo.vo.ConKnowPVo;
import com.xm.service.PsychologyService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class PsychologyController {

    @Resource
    private PsychologyService psychologyService;

    @RequestMapping("/queryPsychology")
    public PsySearch<Psychology> queryPsychology(@RequestBody PsySearch<Psychology> psySearch) throws Exception {
        List<Psychology> psychologies = this.psychologyService.queryPsyAllService(psySearch);
        PageInfo pageInfo=new PageInfo(psychologies);
        PsySearch<Psychology> p=psySearch;
        p.setTotal(pageInfo.getTotal());
        p.setRows(pageInfo.getList());
        return p;
    }

    @RequestMapping("/queryConKnowData")
    public List<ConKnowPVo> queryConknowData() throws Exception {
        List<ConKnowPVo> conKnowPVos = this.psychologyService.queryConKnowService();
        return conKnowPVos;
    }

}
